package ApiController

import (
	"el/app/libs"
	"el/app/models/request"
	"el/app/service"

	"github.com/labstack/echo/v4"
)

type VisitorController struct {
}

func (my *VisitorController) Login(c echo.Context) error {
	visitorLogin := new(request.VisitorLogin)

	if err := c.Bind(visitorLogin); err != nil {
		return libs.Error(c, 1, err.Error())
	}

	visitorLogin.Ip = c.RealIP()

	err := service.VisitorLogin(visitorLogin)

	if err != nil {
		return libs.Error(c, 1, err.Error())
	}
	return libs.Ok(c, nil)
}
